<?php $this->_extends('_layouts/default_layout'); ?>
 
<?php $this->_block('contents'); ?>


<span><a href="<?php echo url('departments/index'); ?>">部门管理</a> &nbsp;&nbsp;&nbsp;查看 <?php echo $dep->department_name; ?> 部门用户</span>

<form action="<?php echo url('departments/deletemember'); ?>" method="post" name="mainform" enctype="multipart/form-data" >
    <table cellpadding="0" cellspacing="0" width="100%">
        <tr class="tth">
            <td width="24%">选择</td>
            <td width="30%">用户名</td>
            <td width="*">用户实名</td>
        </tr>
        <?php foreach ($depusers as $user): ?>		
           <tr>
           <?php if(strlen($user->getUser()->username) > 0): ?>
                <td><input type="checkbox" name="checkboxid[]"  id="checkboxid" value="<?php echo $user->user_id ?>" /></td>
                <td><?php echo $user->getUser()->username ?></td>
                <td><?php echo $user->getUser()->user_realname ?></td>
            <?php endif; ?>
            </tr>
        <?php endforeach; ?>	
            <input type="hidden" name="department_id" id="department_id" value="<?php echo $dep->department_id ?>" />
           <tr>
            <td class="tbutton" colspan="6">
            <input type="button" value="全选" class="btn" onclick="SelectAll()" name="choseall">&nbsp;
            <input type="submit" value="删除" class="btn" name="submit"  onclick="return(CheckFirst())">
            </td>
        </tr>
	</table>
</form>

<script>
	function SelectAll() {
	 var flg=0;
	 var checkboxs=document.getElementsByName("checkboxid[]");
	 var count=0;
	 for (var j=0; j<checkboxs.length; j++)
	 {
		var e=checkboxs[j];
		if(e.checked)count++;
	 }
	 if(count < checkboxs.length)
	 {
		 for (var i=0;i<checkboxs.length;i++) {
			 var e=checkboxs[i];
			 e.checked =1;
			 flg= true;
		 }
	 }
	 else 
	 {
		 for (var i=0;i<checkboxs.length;i++) {
			 var e=checkboxs[i];
			 e.checked =0;
			 flg= false;
		 }

	 }

	 if (flg)
	 {
		document.mainform.choseall.value = "取消";
	 }
	 else
	 {
		document.mainform.choseall.value = "全选";
	 }

	}

	function CheckFirst()
	{
	    var count=0;
        var checkboxs=document.getElementsByName("checkboxid[]");
	    for (var i=0;i<checkboxs.length;i++)
		{
		    var e=checkboxs[i];
		    if(e.checked)count++;
	    }
        if(count == 0)
		{
			alert('请先选择删除条目'); 
			return false;
		}
		else
		{
            if(!confirm('您确认要删除吗?')) 
                return false;
            else
                return true; 
		}
	}
</script>

<?php $this->_endblock(); ?>
